package com.panfeng.xcloud.boss.provider.assets.service.exchange;

import com.alibaba.fastjson.JSONObject;
import com.binance.client.model.enums.CandlestickInterval;
import com.panfeng.xcloud.boss.provider.dto.request.OperateBotReqDTO;
import com.panfeng.xcloud.common.core.candle.CandleEntry;
import com.panfeng.xcloud.common.core.web.vo.InnerTransferVO;
import com.panfeng.xcloud.common.core.web.vo.OrderDetailResponseVO;
import com.panfeng.xcloud.common.core.web.vo.TradeResponseVO;

import java.lang.reflect.InvocationTargetException;
import java.math.BigDecimal;
import java.util.List;

public interface IExchangeMethodService {

    /**
     * 查询账户总可用余额
     *
     * @param userId
     * @param valuationAsset
     * @return
     */
    BigDecimal getTotalAvaliableMoney(String userId, String valuationAsset);

    /**
     * 查询某交易对保证金率
     *
     * @param userId
     * @param contractCode
     * @param direction
     * @return
     */
    BigDecimal getRiskRate(String userId, String contractCode, String direction);

    /**
     * 查询某交易对的可用仓位
     *
     * @param userId
     * @param contractCode
     * @param direction
     * @param leverRate
     * @return
     */
    BigDecimal getAvaliablePosition(String userId, String contractCode, String direction, Integer leverRate);

    /**
     * 查询某交易对的开仓均价
     *
     * @param userId
     * @param contractCode
     * @param direction
     * @param leverRate
     * @return
     */
    BigDecimal getPositionAgvPrice(String userId, String contractCode, String direction, Integer leverRate);

    /**
     * 查询某交易对的可用余额
     *
     * @param userId
     * @param contractCode
     * @return
     */
    BigDecimal getAvaliableMoney(String userId, String contractCode);

    /**
     * 查询某交易对的可开张数
     *
     * @param userId
     * @param destinationCoin
     * @param sourceCoin
     * @param direction
     * @param leverRate
     * @return
     */
    BigDecimal getAvaliablePieces(String userId, String destinationCoin, String sourceCoin, String direction, Integer leverRate);

    /**
     * 交易所下市价单
     *
     * @param operateBotReqDTO
     * @return
     */
    TradeResponseVO trade(OperateBotReqDTO operateBotReqDTO);

    /**
     * 获取订单详情
     *
     * @param operateBotReqDTO
     * @param tradeResponseVO
     * @return
     */
    OrderDetailResponseVO getOrderDetail(OperateBotReqDTO operateBotReqDTO, TradeResponseVO tradeResponseVO) throws InterruptedException;

    /**
     * 同账户内资金划转
     *
     * @param innerTransferVO
     * @return
     */
    String transferInner(InnerTransferVO innerTransferVO);

    /**
     * 获取展示市价
     *
     * @param userId
     * @param destinationCoin
     * @param sourceCoin
     * @return
     */
    BigDecimal getAppearMarketPrice(String userId, String destinationCoin, String sourceCoin);

    /**
     * 获取行情深度,供计算使用
     *
     * @param userId
     * @param destinationCoin
     * @param sourceCoin
     * @return
     */
    JSONObject getMarketPriceDepth(String userId, String destinationCoin, String sourceCoin);

    /**
     * 判断杠杆倍数是否可用
     *
     * @param userId
     * @param destinationCoin
     * @param sourceCoin
     * @param leverRate
     * @return
     */
    boolean leverRateCanUse(String userId, String destinationCoin, String sourceCoin, Integer leverRate);

    /**
     * 调用接口调整杠杆倍数
     *
     * @param userId
     * @param destinationCoin
     * @param sourceCoin
     * @param leverRate
     * @return
     */
    boolean changeLeverRate(String userId, String destinationCoin, String sourceCoin, Integer leverRate);

    /**
     * 获取K线数据
     *
     * @param exchangeType
     * @param userId
     * @param destinationCoin
     * @param sourceCoin
     * @param interval
     * @param startTime
     * @param endTime
     * @param limit
     * @return
     */
    JSONObject getCandleStick(Integer exchangeType, String userId, String destinationCoin, String sourceCoin, CandlestickInterval interval, Long startTime, Long endTime, int limit) throws InterruptedException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
}
